# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libxml++

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.37.1
pkgrel=1
arch=('any')
groups=("${MINGW_PACKAGE_PREFIX}")
pkgdesc="C++ wrapper for the libxml2 XML parser library (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs" "${MINGW_PACKAGE_PREFIX}-libxml2" "${MINGW_PACKAGE_PREFIX}-glibmm")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config")
options=('strip' 'staticlibs')
license=('LGPL')
url="http://libxmlplusplus.sourceforge.net/"
source=("http://ftp.gnome.org/pub/GNOME/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz")
md5sums=('2f9372a6eba6e40206c11f558a8fbc32')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
}

build()
{
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ${srcdir}/${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build="${MINGW_CHOST}" \
    --disable-static \
    --enable-shared

  # Hack for mingw python
  pushd ${MINGW_PREFIX} > /dev/null
  export PREFIX_DEPS=`pwd -W`
  popd > /dev/null
  find . -type f -name "Makefile" -exec sed -i "s|${PREFIX_DEPS}|${MINGW_PREFIX}|g" {} \;
  make
}

package()
{
  cd "${srcdir}/build-${MINGW_CHOST}"
  make install DESTDIR="${pkgdir}"
}
